package demo.springcloud;

import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.cloud.netflix.eureka.EurekaClientConfigBean;
import org.springframework.context.ConfigurableApplicationContext;

/**
 * @author yexi
 * @see EurekaClientConfigBean#EurekaClientConfigBean() 服务端默认地址为 http://localhost:8761/eureka/
 */
@SpringBootApplication
@EnableEurekaClient
@Slf4j
public class EurekaClientDemo {
    public static void main(String[] args) {
        ConfigurableApplicationContext context = SpringApplication.run(EurekaClientDemo.class, args);
        String defaultZone = context.getBean(EurekaClientConfigBean.class).getServiceUrl().get("defaultZone");
        log.info("服务已启动，Eureka服务器访问地址: {}", defaultZone.replace("/eureka/", ""));
    }
}
